#include "comm.hpp"

int main()
{
    //打开文件
    int wfd = open(fifoname.c_str(),O_WRONLY);
    if(wfd < 0)
    {
        cerr<< errno <<" : "<<strerror(errno)<<endl;
        return 1;
    }
    //通信
    char buffer[NUM];
    while(true)
    {
        cout<<"输入你的消息#";
        char* mgs = fgets(buffer ,sizeof(buffer),stdin);
        assert(mgs);
        (void)mgs;
        //假设
        //abcde\n\0
        //012345  strlen = 6 ,但是将5变成0 
        buffer[strlen(buffer) - 1] =0;
        ssize_t n = write(wfd,buffer,strlen(buffer));
        assert(n>0);
        (void)n;
    }



    close(wfd);
}